import { defineStore } from 'pinia'

export const userStore = defineStore('user',{
    //存储全局变量
    state:()=>({
        user:{},    //  用户信息
        loggedIn:false,  //  是否登录
        permissions:[]

    }),
    //同步修改状态信息
    actions:{
        updateUser(user){
            this.user = user;
        },
        updateLoginStatus(status){
            this.loggedIn = status;
        },
        updatePermissions(permissions) {
            this.permissions = permissions;
        }
    },
    persist:{
        enable: true,
        storage: localStorage
    }
})